-
Notifications
You must be signed in to change notification settings - Fork 148
push,build: Use streaming while packing the build context files #2995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
92c0e01 to
b316c6e
Compare
59f647d to
a613b71
Compare
Resolves: #1031 Change-type: patch
a613b71 to
88bb752
Compare
| for (const fileStats of filteredFileList) { | ||
| pack.entry( | ||
| { | ||
| void (async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we create an async function and void it here? Why not keep the for loop as it was before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@myarmolinsky the whole point of this PR is to have this function return the stream w/o having to wait for the whole stream to be constructed (which is what the async-await part does). I'm still (like before) using async-await in here
- b/c I'm using await for the param to the
eolConverter(since I wasn't confident how I could correctly change it to be stream based) - for convenience, since it made it easier to (a)wait till all files are added, before we call
await preFinalizeCallback&pack.finalize()
So the function returns right away the stream reference, and the void allows us to keep the async-await part working in the background and asynchronously add all files in the stream in order and call all required other functions/callbacks.
If we convert eolConverter to be stream based in a separate PR, we can then get rid of the void-async-await, and replace that by adding event listeners on every operation (tbh, I find the async-await code easier to read).
Resolves: #1031
Change-type: patch
See: https://balena.fibery.io/Work/Project/1926